package com.ldw.demo.service;

import com.ldw.demo.dao.UserMapper;
import com.ldw.demo.pojo.Role;
import com.ldw.demo.pojo.User;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class UserServiceImpl implements UserService {
    private UserMapper userMapper;

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public User queryUserByName(String userCode, String userPassword) {
        User user = userMapper.queryUserByName(userCode);
        if(user != null && userPassword.equals(user.getUserPassword())) {
            return user;
        }
        return null;
    }

    @Override
    public User querUserCodeByName(String userCode) {
        User user = userMapper.queryUserByName(userCode);
        return user;
    }

    @Override
    public Boolean pwdModity(HashMap map) {
        int rowCount = userMapper.pwdModity(map);
        if(rowCount > 0) {
            return true;
        }
        return false;
    }

    @Override
    public int getUserCount(Map map) {
        int userCount = userMapper.getUserCount(map);
        return userCount;
    }

    @Override
    public List<User> queryUser(Map map) {
        List<User> userList = userMapper.queryUser(map);
        return userList;
    }

    @Override
    public List<Role> queryRole() {
        List<Role> roleList = userMapper.queryRole();
        return roleList;
    }
}
